#include <iostream>
using namespace std;

int binarySearch(int *nums, int numSize, int target)
{
    int start = 0;
    int end = numSize - 1;
    while (start = end)
    {
        int middle = (start + end) >> 1;

        if (nums[middle] < target)
        {
            start = middle + 1;
        }
        else if (nums[middle] > target)
        {
            end = middle - 1;
        }
        else
        {
            return middle;
        }
    }
    return -1;
}

int main()
{
    int arr[15] = {3, 6, 8, 10, 12, 14, 17, 20, 23, 27, 29, 32, 39, 45, 62};
    int length = sizeof(arr) / sizeof(arr[0]);
    int target = 26;
    int result =binarySearch(arr, length, target);
    if (result != -1)
    {
        cout << "Element found at index: " << result << endl;
    }
    else
    {
        cout << "Element not found" << endl;
    }
    return 0;
}